<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Lemonade Server</title>
  <link rel="icon" href="./favicon.ico">
  <link rel="stylesheet" href="assets/website-styles.css">
</head>
<body>
  <nav class="navbar" id="navbar">
    <div class="navbar-brand">
      <span class="brand-title"><a href="https://lemonade-server.ai">🍋 Lemonade Server</a></span>
    </div>
    <div class="navbar-links">
      <a href="https://github.com/lemonade-sdk/lemonade">GitHub</a>
      <a href="docs/">Docs</a>
      <a href="docs/server/server_models/">Models</a>
      <a href="docs/server/apps/">Featured Apps</a>
      <a href="news/">News</a>
    </div>
  </nav>
  <main class="main">
    <div class="hero-section">
      <div class="main-heading">
        Refreshingly fast LLMs on<br>
        GPUs and NPUs
      </div>
      <div class="subtitle">
        Install, run LLMs locally, and integrate with apps in minutes
      </div>
      <div class="button-row">
        <a class="download-btn" href="https://github.com/lemonade-sdk/lemonade/releases/latest/download/lemonade-server-minimal.msi">
          Download<br>
          <span class="download-sub">for Windows 11</span>
        </a>
        <a class="dev-btn" href="#" onclick="showInstaller(); return false;">
          Developer Setup<br>
          <span class="dev-sub">For Ubuntu, Windows and macOS</span>
        </a>
      </div>
    </div>
    <!-- Community Section -->
    <div class="community-section">
      <div class="subtitle">
        Join the community building the future of local AI
      </div>
      <div class="community-buttons">
        <a href="https://github.com/lemonade-sdk/lemonade" target="_blank" rel="noopener">
          <img src="https://img.shields.io/github/stars/lemonade-sdk/lemonade?label=Star%20on%20GitHub" alt="Star on GitHub" />
        </a>
        <a href="https://discord.gg/5xXzkMu8Zk" target="_blank" rel="noopener">
          <img src="https://img.shields.io/discord/1392562559122407535?style=social&logo=discord&label=Join%20Discord" alt="Join Discord" />
        </a>
      </div>
    </div>
    
    <!-- Video Section -->
    <div class="video-section">
      <div class="video-container">
        <iframe 
          src="https://www.youtube.com/embed/mcf7dDybUco?si=TLSD1EWtvMm1_O3L" 
          title="Getting Started with Lemonade Server" 
          frameborder="0" 
          allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" 
          referrerpolicy="strict-origin-when-cross-origin" 
          allowfullscreen>
        </iframe>
      </div>
    </div>
    
    <!-- Partner Apps Section -->
    <div class="partner-apps">
      <div class="subtitle">
        Lemonade is compatible with the top open-source apps!
      </div>
      <div class="partner-apps-images">
        <a href="https://lemonade-server.ai/docs/server/apps/open-webui/" title="Open WebUI" target="_blank">
          <img src="https://raw.githubusercontent.com/lemonade-sdk/assets/refs/heads/main/partner_logos/openwebui.jpg" alt="Open WebUI" width="60" />
        </a>
        <a href="https://lemonade-server.ai/docs/server/apps/continue/" title="Continue" target="_blank">
          <img src="https://raw.githubusercontent.com/lemonade-sdk/assets/refs/heads/main/partner_logos/continue_dev.png" alt="Continue" width="60" />
        </a>
        <a href="https://github.com/amd/gaia" title="Gaia" target="_blank">
          <img src="https://raw.githubusercontent.com/lemonade-sdk/assets/refs/heads/main/partner_logos/gaia.ico" alt="Gaia" width="60" />
        </a>
        <a href="https://lemonade-server.ai/docs/server/apps/anythingLLM/" title="AnythingLLM" target="_blank">
          <img src="https://raw.githubusercontent.com/lemonade-sdk/assets/refs/heads/main/partner_logos/anything_llm.png" alt="AnythingLLM" width="60" />
        </a>
        <a href="https://lemonade-server.ai/docs/server/apps/ai-dev-gallery/" title="AI Dev Gallery" target="_blank">
          <img src="https://raw.githubusercontent.com/lemonade-sdk/assets/refs/heads/main/partner_logos/ai_dev_gallery.webp" alt="AI Dev Gallery" width="60" />
        </a>
        <a href="https://lemonade-server.ai/docs/server/apps/lm-eval/" title="LM-Eval" target="_blank">
          <img src="https://raw.githubusercontent.com/lemonade-sdk/assets/refs/heads/main/partner_logos/lm_eval.png" alt="LM-Eval" width="60" />
        </a>
          <a href="https://github.com/lemonade-sdk/lemonade-arcade" title="Lemonade Arcade" target="_blank">
            <img src="https://raw.githubusercontent.com/lemonade-sdk/lemonade-arcade/refs/heads/main/docs/assets/favicon.ico" alt="Lemonade Arcade" width="60" />
          </a>
        <a href="https://lemonade-server.ai/docs/server/apps/ai-toolkit/" title="AI Toolkit" target="_blank">
          <img src="https://raw.githubusercontent.com/lemonade-sdk/assets/refs/heads/main/partner_logos/ai_toolkit.png" alt="AI Toolkit" width="60" />
        </a>
      </div>
    </div>
    
    <!-- News Banner Section -->
    <div class="news-banner" id="newsBanner">
      <div class="news-banner-content">
        <a class="news-label" href="https://lemonade-server.ai/news/" target="_blank">LATEST NEWS 📢</a>
        <div class="news-item" id="newsItem">
          <a class="news-title" href="#" id="newsTitle" target="_blank">Loading latest news...</a>
        </div>
      </div>
    </div>
    
    <!-- Release Announcement Section -->
    <div class="release-announcement" id="releaseAnnouncement">
      <div class="release-content">
        <div class="release-info">
          <h3 class="release-title">Latest Release</h3>
          <p class="release-name" id="releaseName">Loading latest release...</p>
          <p class="release-date" id="releaseDate"></p>
          <div class="release-highlights" id="releaseHighlights"></div>
        </div>
      </div>
      <a class="release-link" href="#" id="releaseLink" target="_blank">
        View Release
      </a>
    </div>
  </main>
    <!-- Install Selector View -->
  <div id="lmn-install-view" class="lmn-install-view">
    <span class="lmn-install-title">Installation Setup</span>
    <div id="lmn-installer" class="lmn-installer-container">
      <!-- Content will be dynamically generated by install-selector.js -->
    </div>
  </div>
  
  <!-- Footer will be inserted here by footer.js -->
  <div class="footer-placeholder"></div>
  
  <script src="assets/install-selector.js"></script>
  <script src="assets/footer.js"></script>
  <script src="assets/news-data.js"></script>
  <script>
    // Load latest news item
    function loadLatestNews() {
      try {
        if (typeof newsData !== 'undefined' && newsData.length > 0) {
          // Filter out releases
          const nonReleaseNews = newsData.filter(item => item.type !== 'release');
          if (nonReleaseNews.length > 0) {
            // Sort by date descending
            nonReleaseNews.sort((a, b) => {
              const dateA = new Date(a.date);
              const dateB = new Date(b.date);
              return dateB - dateA;
            });
            // Get the 3 most recent items
            const latestNewsItems = nonReleaseNews.slice(0, 3);
            const newsItemContainer = document.getElementById('newsItem');
            if (newsItemContainer) {
              // Clear previous content
              newsItemContainer.innerHTML = '';
              
              // Create a ticker container with individual links
              const tickerContainer = document.createElement('div');
              tickerContainer.className = 'news-ticker-container';
              
              // Create three repetitions of the news items for seamless scrolling
              for (let rep = 0; rep < 3; rep++) {
                latestNewsItems.forEach((item, idx) => {
                  const newsLink = document.createElement('a');
                  newsLink.className = 'news-ticker-item';
                  newsLink.href = item.url;
                  newsLink.target = '_blank';
                  newsLink.textContent = item.title;
                  tickerContainer.appendChild(newsLink);
                  
                  // Add separator if not the last item in the last repetition
                  if (!(rep === 2 && idx === latestNewsItems.length - 1)) {
                    const separator = document.createElement('span');
                    separator.className = 'news-ticker-separator';
                    separator.textContent = ' • ';
                    tickerContainer.appendChild(separator);
                  }
                });
              }
              
              newsItemContainer.appendChild(tickerContainer);
            }
          }
        }
      } catch (error) {
        console.error('Error loading news:', error);
        // Fallback content
        const newsItemContainer = document.getElementById('newsItem');
        if (newsItemContainer) {
          newsItemContainer.innerHTML = '';
          const link = document.createElement('a');
          link.className = 'news-title';
          link.href = 'https://lemonade-server.ai/news/';
          link.target = '_blank';
          link.textContent = 'Check our latest updates';
          newsItemContainer.appendChild(link);
        }
      }
    }
    
    // Fetch latest release from GitHub API
    async function fetchLatestRelease() {
      try {
        const response = await fetch('https://api.github.com/repos/lemonade-sdk/lemonade/releases/latest');
        const release = await response.json();
        
        // Update the release announcement
        const releaseName = document.getElementById('releaseName');
        const releaseDate = document.getElementById('releaseDate');
        const releaseLink = document.getElementById('releaseLink');
        const releaseHighlights = document.getElementById('releaseHighlights');
        
        if (release.name) {
          releaseName.textContent = release.name;
          releaseDate.textContent = `Released ${new Date(release.published_at).toLocaleDateString('en-US', { 
            year: 'numeric', 
            month: 'long', 
            day: 'numeric' 
          })}`;
          releaseLink.href = release.html_url;
          
          // Parse and display headline items
          if (release.body) {
            const headlines = parseHeadlineSection(release.body);
            if (headlines.length > 0) {
              releaseHighlights.innerHTML = headlines.map(item => `<div class="highlight-item">${item}</div>`).join('');
            }
          }
        } else {
          // Fallback if no release name
          releaseName.textContent = release.tag_name || 'Visit GitHub for Latest Release';
          if (release.published_at) {
            releaseDate.textContent = `Released ${new Date(release.published_at).toLocaleDateString('en-US', { 
              year: 'numeric', 
              month: 'long', 
              day: 'numeric' 
            })}`;
          } else {
            releaseDate.textContent = 'Check for updates';
          }
          releaseLink.href = release.html_url;
        }
      } catch (error) {
        console.error('Error fetching release:', error);
        // Fallback content
        document.getElementById('releaseName').textContent = 'Visit GitHub for Latest Release';
        document.getElementById('releaseDate').textContent = 'Check for updates';
        document.getElementById('releaseLink').href = 'https://github.com/lemonade-sdk/lemonade/releases/latest';
      }
    }
    
    // Parse the headline section from release body
    function parseHeadlineSection(body) {
      const lines = body.split('\n');
      const headlines = [];
      let inHeadlineSection = false;
      
      for (const line of lines) {
        if (line.trim() === '## Headline') {
          inHeadlineSection = true;
          continue;
        }
        
        if (inHeadlineSection) {
          if (line.trim().startsWith('## ')) {
            // End of headline section
            break;
          }
          
          if (line.trim().startsWith('- ')) {
            // Extract headline item, remove markdown formatting
            let item = line.trim().substring(2).trim();
            // Remove backticks for cleaner display
            item = item.replace(/`([^`]+)`/g, '$1');
            item = item.trim();
            headlines.push(item);
          }
        }
      }
      
      return headlines;
    }
    
    // Fetch GitHub stats
    async function fetchGitHubStats() {
      // No longer needed for shields.io badges
    }
    
    // Load release info when page loads
    document.addEventListener('DOMContentLoaded', function() {
      loadLatestNews();
      fetchLatestRelease();
      
      // Initialize footer with star count - add debug logging
      console.log('Initializing footer...');
      initializeFooter();
      console.log('Footer initialization called');
      
      // Initialize the installer if we're on the installer view
      if (document.getElementById('lmn-install-view').style.display === 'flex') {
        if (typeof lmnInit === 'function') {
          lmnInit();
        }
      }
    });
    
    function showInstaller() {
      document.querySelector('.main').classList.add('hidden');
      document.getElementById('lmn-install-view').style.display = 'flex';
      
      // Initialize the installer after the view is shown
      setTimeout(function() {
        if (typeof lmnInit === 'function') {
          console.log('Initializing installer...');
          lmnInit();
        } else {
          console.error('lmnInit function not found');
        }
      }, 100);
    }
    
    function showMain() {
      document.querySelector('.main').classList.remove('hidden');
      document.getElementById('lmn-install-view').style.display = 'none';
      document.getElementById('navbar-context').classList.remove('show');
    }
  </script>
</body>
</html>
